home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 16
/
Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso
/
Aminet
/
util
/
time
/
EZCron.lha
/
EZCron
< prev
next >
Wrap
Text File
|
1996-10-03
|
10KB
|
312 lines
/* EZCron by Jim Hines v1.71 ©1995-1996 All Rights Reserved
**
** 10-23-95 Added requester to verify making a NEW cron.config file. See newrtn:
** 10-25-95 Fixed Bug in the above and added renaming of the old config file. See newrtn:
** renamed from ACron to EZCron. GUI started on this date too.
** 11-30-95 added the text string reminder support and the sfx functions
** 12-05-95 Fixed case sensitivity problem with weekly, monthly & Daily routines
** 12-13-95 Added Speech Function
** 01-04-96 Added Weekdays, Weekend and Quarterly support functions
** 01-05-96 Fixed a bug in the Weekdays routine.
** 01-11-96 Cleaned up the code a bit
** 01-17-96 Added a new routine. ie every_3_wed
** 08-25-96 Moved the cron.config file to envarc: / RAM:ENV
** Good idea Paul. ;)
** 09-02-96 Moved the active config file to ram:t as the env: was causing HD
** activity with such programs as HDEnv
** 09-10-96 Hourly time range routine added.
** 09-11-96 Fixed a nasty bug in time range and majorly rearranged the timer code.
** Version bumped to 1.70. Thanks Gene!
** Finally renamed the rexx port from ACron_Rexx to EZCron_Rexx.
** 09-18-96 Added the every 'Five_Min' time field.
** 10-03-96 Actually made it work (What took me so long?)
*/
csi='9b'x
Ital=csi'3m'
bold=csi'1m'
norm=csi'0m'
black=csi'31m'
white=csi'32m'
blue=csi'33m'
LF = '0a'x
/* ========END VARABLES == */
arg command lg .
if ~show('L','rexxsupport.library') then
call addlib('rexxsupport.library',0,-30)
/* if ~show('L','rexxreqtools.library') then
call addlib("rexxreqtools.library", 0, -30, 0)
*/
address command 'copy s:cron.config t:' /* Added 9-02-96 */
/* ======== THIS IS THE INPUT PARSING / USAGE SECTION WITH A SUB-ROUTINE== */
select
when command = 'START' then call startrtn()
when command = "STOP" then call stoprtn()
when command = "QUIT" then call stoprtn()
otherwise
say ''
say bold'ERROR,'norm 'Unknown option'blue command norm
call nulinp()
end
stoprtn:
if command = "STOP" then do
if showlist('P', 'EZCRON_REXX') then do
say ital 'Exiting EZCron: Please Wait. Program will exit in' LT 'seconds!' norm
address 'EZCRON_REXX' STOP
exit
end
end
else
say bold ital 'EZCron is not running.' norm
exit
end
/* =======LOOP== */
startrtn:
if ~exists('t:cron.config') then do
call rtezrequest('cron.config does NOT exist', "Okay", , "rt_reqpos = reqpos_centerscr")
exit
end
RC = showlist('P', 'EZCRON_REXX')
if RC = 1 then do
say bold ital white 'EZCron is Already Active' norm
exit
end
openport('EZCRON_REXX')
SIGNAL on HALT
/* =======PARSE CONFIG FILE & TIMER SECTION == */
do forever
sec = right(time('N'),2) /* get seconds */
sec2 = 60 - sec /* 60 (seconds) minus sec) */
delayvar = sec2 * 50 /* sec2 x 50 ticks or 1 second sets the delay time */
LT = delayvar / 50
LTime = 60 - LT
call delay(delayvar) /* 3000 would be equal to 1 minute */
/* ======== AREXX PORT STUFF == */
pkt = getpkt('EZCRON_REXX')
if pkt ~= '0000 0000'x then call aport(pkt)
clock = time('N')
clock2 = LEFT(clock,5)
date = Date(USA) /* 08/04/92 */
date2 = Date(S) /* 19920804 */
date3 = Date(W, date2, 'S') /* Friday */
config = 't:cron.config' /* Name of file for reading events from */
event. = 0
if ~open(cronfile, config,'READ') then do
exit 20
end
errors = 0
do until eof(cronfile)
/* Grab the line, parse the event and ignore the comments */
linein = readln(cronfile)
parse var linein line '#'
next = event.0 + 1
parse var line event.next.command event.next.pargs1 event.next.pargs2,
event.next.pargs3 event.next.pargs4 event.next.time event.next.date,
event.next.rng1 event.next.rng2 event.next.sfx event.next.txt
event.next.date = translate(event.next.date, 'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
/* THE ABOVE TRANSLATES THE DATE TO LOWERCASE IF NOT NUMERIC */
event.next.time = translate(event.next.time, 'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
/* THE ABOVE TRANSLATES THE TIME TO LOWERCASE IF NOT NUMERIC */
select
when event.next.command = "" then iterate
when event.next.command = "" then do
say "Not enough fields in:" linein
errors = 1
iterate
end
otherwise event.0 = next
end
end /* end of the do until eof loop */
call close(cronfile)
/* ======== END OF PARSE SECTION == */
do i = 1 to event.0
/* ======= Arguments Routine == */
if event.i.pargs1 = '-' then event.i.pargs1 = ''
if event.i.pargs2 = '-' then event.i.pargs2 = ''
if event.i.pargs3 = '-' then event.i.pargs3 = ''
if event.i.pargs4 = '-' then event.i.pargs4 = ''
/* ======= Misc Routines == */
if event.i.sfx = '-' then event.i.sfx = ''
if event.i.txt = '-' then event.i.txt = ''
/* ======= Every Minute Routine == */
if event.i.time = 'minute' then event.i.time = clock2
/* ======= Every Five Minute Routine == */
if event.i.time = 'five_min' then do
parse var clock2 dontneedme ':' minfive
fiveresult = minfive / 5
parse var fiveresult intmin '.' decsec
end
if decsec = '' then event.i.time = clock2 /* if there is a remainder, get out!! */
drop dontneedme minfive fiveresult intmin decsec
/* ======= Quarterly Routine == */
parse var clock2 hrs ':' min
drop hrs
if min = 00 & event.i.time = 'quarterly' then event.i.time = clock2
if min = 15 & event.i.time = 'quarterly' then event.i.time = clock2
if min = 30 & event.i.time = 'quarterly' then event.i.time = clock2
if min = 45 & event.i.time = 'quarterly' then event.i.time = clock2
/* ======= Every Hour Routine == */
if min = 00 & event.i.time = 'hourly' then event.i.time = clock2
/* ======= Daily Routine == */
if event.i.date = 'daily' then event.i.date = date
/* ======= Weekly Routine == */
if event.i.date = 'sunday' & date3 = 'Sunday' then event.i.date = date
if event.i.date = 'monday' & date3 = 'Monday' then event.i.date = date
if event.i.date = 'tuesday' & date3 = 'Tuesday' then event.i.date = date
if event.i.date = 'wednesday' & date3 = 'Wednesday' then event.i.date = date
if event.i.date = 'thursday' & date3 = 'Thursday' then event.i.date = date
if event.i.date = 'friday' & date3 = 'Friday' then event.i.date = date
if event.i.date = 'saturday' & date3 = 'Saturday' then event.i.date = date
/* ======= Weekdays Routine == The 'ol Mon-Fri routine */
if event.i.date = 'weekdays' & date3 ~= 'Sunday' & date3 ~= 'Saturday'
then event.i.date = date
/* ======= Weekend Routine == The ol' Sat & Sun routine */
if event.i.date = 'weekend' & date3 = 'Saturday' then event.i.date = date
if event.i.date = 'weekend' & date3 = 'Sunday' then event.i.date = date
/* ======= Monthly Routine == */
month.event = event.i.date
parse var month.event mth '-' day2
if mth = 'monthly' then do
parse var date month '/' day '/' year
if day2 = day & event.i.time = clock2 then event.i.date = date
end
/* ======= # 4th Fri, 2nd Tue, etc routine == */
parse var event.i.date var1 '_' num '_' dow /* every 2 wed */
if var1 = 'every' then do
del3 = date(n) /* 20 Apr 88 */
parse var del3 del1 cm del2
drop del1 del2 /* dont even need them */
if cm = 'Jan' then cm = 31;if cm = 'Feb' then cm = 28 /* This is for 1996. Will need to be changed to 28 after Feb 29. */
if cm = 'Mar' then cm = 31;if cm = 'Apr' then cm = 30
if cm = 'May' then cm = 31;if cm = 'Jun' then cm = 30
if cm = 'Jul' then cm = 31;if cm = 'Aug' then cm = 31
if cm = 'Sep' then cm = 30;if cm = 'Oct' then cm = 31
if cm = 'Nov' then cm = 30;if cm = 'Dec' then cm = 31
countvar = 0
do z = 1 to cm
currdate = date(s) /* 19951221 year month day */
yearmonth = left(currdate, 6) /* 199512 year month */
if z < 10 then do
zdate = yearmonth'0'z /* 19951201 */
newz = '0'z
end
else do
zdate = yearmonth''z /* 19951231 */
newz = z
end
myday = Date(W, zdate, 'S') /* Friday */
myday = left(myday, 3) /* Fri */
myday = translate(myday, 'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') /* fri */
if myday = dow then countvar = countvar + 1
if myday = dow & countvar = num then do
year = left(zdate, 4) /* 1995 */
year2 = right(year, 2) /* 95 */
month = right(zdate, 4) /* 1221 */
month2 = left(month, 2) /* 12 */
event.i.date = month2'/'newz'/'year2
leave
end
end
end
/* ======= Time Range routine == */
range = ''
hrs = time(h)
if hrs < 10 then hrs = 0||hrs
if event.i.rng1 ~= '--' then do
if event.i.rng1 <= hrs & event.i.rng2 > hrs then do
range = runitnow
end
if range ~= runitnow then event.i.time = void_event
end
/* ======= Final Routine == */
if event.i.time = clock2 & event.i.date = date then
address command 'run >NIL:' event.i.command event.i.pargs1,
event.i.pargs2 event.i.pargs3 event.i.pargs4
if event.i.time = clock2 & event.i.date = date & event.i.sfx ~= "" then do
if exists('EZCron:prefs/sfx.prefs') then do
open(sfxconfig, 'EZCron:prefs/sfx.prefs', 'r')
sfxplayer = readln(sfxconfig)
close(sfxconfig)
address command 'run >nil:' sfxplayer event.i.sfx
end
end
if event.i.time = clock2 & event.i.date = date & event.i.txt ~= "" then do
address command 'run >nil: rx >nil: ezcron:rexx/Reminder.rexx' event.i.txt /*This calls the external rexx proggy for the event display */
if showlist(h,SPEAK) then do
address command 'echo' event.i.txt '>speak:'
end
end
if event.i.time = clock2 & event.i.date = date
then event.i.date = 'Finished with Event'
end /* end of 'do i = 1 to event.0' */
end /* end of do forever */
/* ======== CLEANUP == */
if event.0 = 0 then exit
options failat 300
trace 'Off'
/* ======== Arexx Port Message Check == */
aport:
Cmd = getarg(Pkt)
if Cmd = 'STOP' then do
call reply(Pkt, rc)
exit
end